package cn.com.guage.dtm;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 启动程序
 * 
 * 
 */

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class DtmToolsApplication {

	protected final Logger logger = LoggerFactory.getLogger(this.getClass());

	public static void main(String[] args) {
		// System.setProperty("spring.devtools.restart.enabled", "false");
		SpringApplication.run(DtmToolsApplication.class, args);
	}

	@Bean
	public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
		logger.info("开始执行：--------------------------");
		return args -> {
			String[] beanNames = ctx.getBeanDefinitionNames();
			for (String beanName : beanNames) {
				Class<?> beanType = ctx.getType(beanName);
				Package beanPackage = beanType.getPackage();
				logger.info("BeanName:" + beanName);
				logger.info("Bean的类型：" + beanType);
				logger.info("Bean所在的包：" + beanPackage);

				logger.info("\r\n");
			}
			logger.info("执行结束：--------------------------");
		};

	}
}
